<template>
  <div class="shop-info" v-if="Object.keys(shop).length !== 0">
    <div class="shop-top">
      <img :src="shop.logo" :alt="shop.name" class="shop-logo">
      <span class="shop-name">{{ shop.name }}</span>
    </div>
    <div class="shop-middle">
      <div class="shop-middle-left">
        <div class="sells">
          <div>{{ shop.sells |sellsFilter }}</div>
          <div class="goods-sells">总销量</div>
        </div>
        <div class="goods-count">
          <div>{{ shop.goodsCount }}</div>
          <div class="goods-sells">全部宝贝</div>
        </div>
      </div>
      <div class="shop-middle-right">
        <table>
          <tr v-for="item in shop.score">
            <td class="score-name">{{ item.name }}</td>
            <td class="score-score worsefont" :class="{betterfont:item.isBetter}">{{ item.score }}</td>
            <td class="score-grade " ><span class="worse" :class="{better:item.isBetter}">{{ item.isBetter ? '高' : '低' }}</span></td>
          </tr>
        </table>
      </div>
    </div>
    <div class="shop-bottom">
      <div class="look">进店逛逛</div>
    </div>
  </div>
</template>

<script>
export default {
  name: "DetailShopInfo",
  props: {
    shop: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  filters: {
    // 使用过滤器给售卖数添加单位
    sellsFilter(val) {
      if(val<10000)
        return val+'万'
      return (val/10000).toFixed(1)+'万'
    }
  }
}
</script>

<style scoped>
/*整体样式*/
.shop-info {
  padding: 20px 10px;
  border-bottom: 5px solid #F2F5F8;
}

/*上面logo*/
.shop-top {
  line-height: 45px;
  display: flex;
  align-items: center;
}

.shop-top .shop-name {
  margin-left: 10px;
}

.shop-top .shop-logo {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .1);
}

/*中间评价*/
.shop-middle {
  display: flex;
  margin-top: 15px;
  /*可以让盒子居中且高度不被拉伸*/
  align-items: center;
  color: #333333;

}

.shop-middle > div {
  flex: 1;
}

.shop-middle .shop-middle-left {
  display: flex;
  justify-content: space-evenly;
  text-align: center;
  border-right: 1px solid #ccc;
}

.shop-middle .shop-middle-left .goods-sells {
  margin-top: 10px;
  font-size: 12px;
}

.shop-middle .shop-middle-right {
  display: flex;
  justify-content: center;
  font-size: 12px;
  /*margin-left: 30px;*/
}
.shop-middle .shop-middle-right td{
  padding: 5px 0;
}
.shop-middle .shop-middle-right .score-name {
  padding-right: 5px;
}

.shop-middle .shop-middle-right .score-score {
  padding-right: 3px;
}

.shop-middle .shop-middle-right .score-grade {
  color: #fff;
}

/*底部按钮*/
.shop-bottom {
  font-size: 13px;
  text-align: center;
}

.shop-bottom .look {
  display: inline-block;
  margin-top: 20px;
  background-color: #F2F5F8;
  width: 140px;
  padding: 6px;
  border-radius: 10px;
}

/*公共样式*/
.worse {
  background-color: #5EA732;
}

.worsefont {
  color: #5EA732;
}
.better {
  background-color: #F13E3A;
}

.betterfont {
  color: #F13E3A;
}
</style>
